<?php
/* @var $this AdminController */
/* @var $dataProvider CActiveDataProvider */
?>

<h2>Пользователи</h2>
<?php if(isset($_GET['status']) && $_GET['status'] == 'success'):?>
	<div class="alert alert-success">
		Данные успешно сохранены
	</div>
<?endif;?>
<table class="table table-bordered table-striped">
	<tr>
		<th>ID</th>
		<th>Имя</th>
		<th>Роли</th>
		<th>E-mail</th>
		<th>Действие</th>
	</tr>
	<?php foreach ($model as $user):?>
		<tr>
			<td><?php echo $user['ID'];?></td>
			<td><?php echo $user['name'], " ", $user['lastname'];?></td>
			<td>
				<?php $roles = Yii::app()->authManager->getAuthItems(2, $user['ID']);?>
				<ol>
					<?php foreach($roles as $role):?>
						<?php $desc = $role->getDescription();?>
						<li><?php echo empty($desc) ? $role->getName() : $desc;?></li>
					<?php endforeach;?>
				</ol>
			</td>
			<td><?php echo $user['email'];?></td>
			<td>
				<a href="<?php echo $this->createUrl('/user/default/update', array('id'=>$user['ID']))?>">Изменить</a>
				<br>
				<a href="<?php echo $this->createUrl('/user/default/delete', array('id'=>$user['ID']))?>">Удалить</a>
			</td>
		</tr>
	<?php endforeach;?>
</table>